using MediatR;
using S.M.SmartMedical.ErrorCode;
using S.M.SmartMedical.Domain.Enums;

namespace S.M.SmartMedical.API.Write.Application.Command;

/// <summary>
/// 更新开单申请状态命令
/// </summary>
public class UpdateOrderStatusCommand : IRequest<APIResult<bool>>
{
    /// <summary>
    /// 开单申请ID
    /// </summary>
    public int OrderApplicationId { get; set; }
    
    /// <summary>
    /// 新状态
    /// </summary>
    public OrderApplicationStatus Status { get; set; }
    
    /// <summary>
    /// 用户ID（用于权限验证）
    /// </summary>
    public int? UserId { get; set; }
    
    /// <summary>
    /// 状态更新备注
    /// </summary>
    public string? Remarks { get; set; }
    
    /// <summary>
    /// 支付方式（当状态为已支付时）
    /// </summary>
    public string? PaymentMethod { get; set; }
    
    /// <summary>
    /// 支付交易号（当状态为已支付时）
    /// </summary>
    public string? PaymentTransactionId { get; set; }
    
    /// <summary>
    /// 支付时间（当状态为已支付时）
    /// </summary>
    public DateTime? PaymentTime { get; set; }
}

/// <summary>
/// 支付开单申请命令
/// </summary>
public class PayOrderApplicationCommand : IRequest<APIResult<PaymentResultDto>>
{
    /// <summary>
    /// 开单申请ID
    /// </summary>
    public int OrderApplicationId { get; set; }
    
    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }
    
    /// <summary>
    /// 支付方式
    /// </summary>
    public string PaymentMethod { get; set; } = string.Empty;
    
    /// <summary>
    /// 支付金额
    /// </summary>
    public decimal PaymentAmount { get; set; }
    
    /// <summary>
    /// 支付交易号
    /// </summary>
    public string? PaymentTransactionId { get; set; }
}

/// <summary>
/// 支付结果数据传输对象
/// </summary>
public class PaymentResultDto
{
    /// <summary>
    /// 开单申请ID
    /// </summary>
    public int OrderApplicationId { get; set; }
    
    /// <summary>
    /// 申请编号
    /// </summary>
    public string ApplicationNumber { get; set; } = string.Empty;
    
    /// <summary>
    /// 支付状态
    /// </summary>
    public bool PaymentSuccess { get; set; }
    
    /// <summary>
    /// 支付时间
    /// </summary>
    public DateTime PaymentTime { get; set; }
    
    /// <summary>
    /// 支付金额
    /// </summary>
    public decimal PaymentAmount { get; set; }
    
    /// <summary>
    /// 支付方式
    /// </summary>
    public string PaymentMethod { get; set; } = string.Empty;
    
    /// <summary>
    /// 支付交易号
    /// </summary>
    public string? PaymentTransactionId { get; set; }
    
    /// <summary>
    /// 订单状态
    /// </summary>
    public OrderApplicationStatus Status { get; set; }
}